package cn.yhbk.web.modules.manager.Service.Impl;

import cn.yhbk.web.modules.manager.Pojo.Entity.TbItems;
import cn.yhbk.web.modules.manager.Mapper.TbItemsMapper;
import cn.yhbk.web.modules.manager.Service.ITbItemsService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.logging.log4j.util.Strings;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * <p>
 * 活动表 服务实现类
 * </p>
 *
 * @author 有何不可
 * @since 2024-02-04
 */
@Service
public class TbItemsServiceImpl extends ServiceImpl<TbItemsMapper, TbItems> implements ITbItemsService {

    @Override
    public TbItems checkActivity(String key) {
        LambdaQueryWrapper<TbItems> lambda = new QueryWrapper<TbItems>().lambda();
        lambda.eq(TbItems::getKey,key);

        List<TbItems> list = list(lambda);
        return list.get(0);
    }

    @Override
    public List<String> getActivityKey() {
        LambdaQueryWrapper<TbItems> lambda = new QueryWrapper<TbItems>().lambda();

        lambda.select(TbItems::getKey);
        lambda.isNotNull(TbItems::getKey);
        List<TbItems> list = list(lambda);
        return list.stream().filter(item->!Objects.isNull(item)).map(TbItems::getKey).collect(Collectors.toList());
    }
}
